package com.mgy.db.common.query;

import lombok.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * (BigData)实体查询类
 *
 * @author maguoyong
 * @since 2020-01-29 12:07:31
 */
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class BigDataQuery extends BaseQuery {

    private static final long serialVersionUID = 284086246799925805L;


    /**
     * ${column.comment}
     */
    private Integer id;

    /**
     * ${column.comment}
     */
    private String name;

    /**
     * ${column.comment}
     */
    private String sex;

    /**
     * ${column.comment}
     */
    private Integer age;

    /**
     * ${column.comment}
     */
    private Integer height;

    /**
     * ${column.comment}
     */
    private Integer weight;

    /**
     * ${column.comment}
     */
    private String grade;

    /**
     * ${column.comment}
     */
    private String className;

    /**
     * ${column.comment}
     */
    private String introduction;

    /**
     * ${column.comment}
     */
    private String nation;

    /**
     * ${column.comment}
     */
    private String nativePlace;

    /**
     * ${column.comment}
     */
    private String abodePlace;
    private Date createdEqual;
    /**
     * ${column.comment}
     */
    private Date createdStart;
    /**
     * ${column.comment}
     */
    private Date createdEnd;

    private Date modifiedEqual;
    /**
     * ${column.comment}
     */
    private Date modifiedStart;
    /**
     * ${column.comment}
     */
    private Date modifiedEnd;


    @Builder.Default
    private List<OrderField> orderFields = new ArrayList<OrderField>();

    /**
     * 设置排序按属性：id
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyId(boolean isAsc) {
        orderFields.add(new OrderField("id", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：name
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyName(boolean isAsc) {
        orderFields.add(new OrderField("name", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：sex
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbySex(boolean isAsc) {
        orderFields.add(new OrderField("sex", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：age
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyAge(boolean isAsc) {
        orderFields.add(new OrderField("age", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：height
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyHeight(boolean isAsc) {
        orderFields.add(new OrderField("height", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：weight
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyWeight(boolean isAsc) {
        orderFields.add(new OrderField("weight", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：grade
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyGrade(boolean isAsc) {
        orderFields.add(new OrderField("grade", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：className
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyClassName(boolean isAsc) {
        orderFields.add(new OrderField("class_name", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：introduction
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyIntroduction(boolean isAsc) {
        orderFields.add(new OrderField("introduction", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：nation
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyNation(boolean isAsc) {
        orderFields.add(new OrderField("nation", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：nativePlace
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyNativePlace(boolean isAsc) {
        orderFields.add(new OrderField("native_place", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：abodePlace
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyAbodePlace(boolean isAsc) {
        orderFields.add(new OrderField("abode_place", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：created
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyCreated(boolean isAsc) {
        orderFields.add(new OrderField("created", isAsc ? "asc" : "desc"));
    }

    /**
     * 设置排序按属性：modified
     *
     * @param isAsc 是否升序，否则为降序
     */
    public void orderbyModified(boolean isAsc) {
        orderFields.add(new OrderField("modified", isAsc ? "asc" : "desc"));
    }

    public class OrderField {
        private String fieldName;
        private String order;
        public OrderField(String fieldName, String order) {
            super();
            this.fieldName = fieldName;
            this.order = order;
        }

        public String getFieldName() {
            return fieldName;
        }

        public void setFieldName(String fieldName) {
            this.fieldName = fieldName;
        }

        public String getOrder() {
            return order;
        }

        public void setOrder(String order) {
            this.order = order;
        }
    }

}